#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "RoomManagerFunctionLibrary.generated.h"

class URoomManagerSubsystem;
class URoomLightManagerSubsystem;
/**
 * 
 */
UCLASS()
class PHOBIA_API URoomManagerFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable, meta=(WorldContext="WorldContextObject"))
	static URoomManagerSubsystem* GetRoomManagerSubsystem(const UObject* WorldContextObject);

	UFUNCTION(BlueprintCallable, meta=(WorldContext="WorldContextObject"))
	static URoomLightManagerSubsystem* GetRoomLightManagerSubsystem(const UObject* WorldContextObject);

	UFUNCTION(BlueprintCallable, meta=(WorldContext="WorldContextObject"))
	static FName GetActorRoomName(const UObject* WorldContextObject, AActor* InActor);

	UFUNCTION(BlueprintCallable)
	static bool IsValidRoomName(const FName& RoomName);

	template <typename SubsystemType>
	static SubsystemType* GetGameInstanceSubsystem(const UObject* WorldContextObject);
};

template <typename SubsystemType>
SubsystemType* URoomManagerFunctionLibrary::GetGameInstanceSubsystem(const UObject* WorldContextObject)
{
	if (UWorld* World = WorldContextObject->GetWorld())
	{
		if (UGameInstance* GameInstance = World->GetGameInstance())
		{
			return GameInstance->GetSubsystem<SubsystemType>();
		}
	}

	return nullptr;
}
